package com.tm.test;

import com.tm.util.DBUtil;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class SelectStudent {

    private static Connection conn = null;
    private static Statement stmt = null;
    private static ResultSet rs = null;

    public static void main(String[] args) {
        conn = DBUtil.getConn();

        String sql = "select * from stu limit 5, 50";

        try {
            stmt = conn.createStatement();

            rs = stmt.executeQuery(sql);

            while (rs.next()){
                int sid = rs.getInt(1);
                String name = rs.getString(2);
                String sex = rs.getString(3);
                int cid = rs.getInt(4);

                System.out.println(sid + " " + name + " " + sex + " " + cid);
            }
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }

        DBUtil.closeAll(conn, stmt, rs);
    }
}
